SNPs<- read.table("23andMe_complete.txt", header = TRUE, sep = "\t")
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(tidyverse)
## ── Attaching packages ───────────────────────────────── tidyverse 1.3.0 ──
## ✓ tibble 2.1.3 ✓ dplyr 0.8.4
## ✓ tidyr 1.0.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.4.0
## ✓ purrr 0.3.3
## ── Conflicts ──────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks plotly::filter(), stats::filter()
## x dplyr::lag() masks stats::lag()
library(DT)
library(ggplot2)
#exercise 1
ggplot(data = SNPs) +
geom_bar( mapping = aes(x = chromosome), fill = "blue") +
ggtitle("Total SNPs for each chromosome") +
ylab("Total number of SNPs") +
xlab("Chromosome")
#exercise 2
mycolor<-c("AA"="red","AC"="red","AG"="red","AT"="red","CC"="red","CG"="red","CT"="red","DD"="blue","DI"="blue","D"="blue","I"="blue","II"="blue","GG"="red","GT"="red","TT"="red","A"="yellow","C"="yellow","G"="yellow","T"="yellow","--" = "magenta")
p <- ggplot(SNPs, aes(x = chromosome, fill = genotype))
p <- p + geom_bar() +
ggtitle("Total SNPs for each chromosome") +
ylab("Genotype Count") +
xlab("Chromosome Numbers") +
scale_fill_manual(values=c(mycolor))
p
#exercise 3
Total SNPs for each chromosome
#exercise 4
Total SNPs for each chromosome
#exercise 5
ggplotly(
ggplot(data = SNPs) +
geom_bar(mapping = aes(x = chromosome, fill = genotype)) +
facet_wrap(~ genotype, ncol = 3, nrow = 15, scales = "fixed") +
theme(axis.text.x = element_text( size = 3),) +
theme(axis.text = element_text( size = 5),) +
ggtitle("Total SNPs for each chromosome") +
ylab("Genotype Count") +
xlab("Chromosome Numbers")
)
#exercise 6
R <- subset(SNPs, chromosome == "Y" )
datatable(R)
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html